package com.qfedu.lc.app.controller;


import com.qfedu.lc.app.service.UserFeign;
import com.qfedu.lc.common.config.SystemConfig;
import com.qfedu.lc.common.param.UserAdd;
import com.qfedu.lc.common.param.UserLogin;
import com.qfedu.lc.common.vo.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;


@Api(value = "用户相关接口")
@RestController
@RequestMapping("/api/user")
public class UserController {

    @Autowired
    private UserFeign userFeign;

    /**
     * 注册接口
     *
     * @param userAdd
     * @return
     */
    @ApiOperation(value = "注册接口")
    @RequestMapping(value = "/register",method = RequestMethod.POST)
    public R register(@RequestBody UserAdd userAdd) {

        return userFeign.register(userAdd);

    }
    @ApiOperation(value = "账号 密码登录接口")
    @RequestMapping(value = "/loginpass",method = RequestMethod.POST)
    public R loginPass(@RequestBody UserLogin userLogin) {

        return userFeign.loginPass(userLogin);
    }

    @ApiOperation(value = "退出接口")
    @RequestMapping(value = "/logout",method = RequestMethod.GET)
    public R logout(HttpServletRequest request){
        String token = request.getHeader(SystemConfig.HEADER_TOKEN);
        return userFeign.logout();
    }


}